package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookPicture;
import com.pgybook.db.entity.domain.BookPictureEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookPictureMapper {
    int countByExample(BookPictureEx example);

    int deleteByExample(BookPictureEx example);

    @Delete({
            "delete from bookpicture",
            "where PICTUREID = #{pictureid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long pictureid);

    @Insert({
            "insert into bookpicture (BOOKID, MAINPIC, ",
            "DISPLAYORDER, PICFORMAT, ",
            "STATUS, SIZE, CONTENT)",
            "values (#{bookid,jdbcType=BIGINT}, #{mainpic,jdbcType=BIT}, ",
            "#{displayorder,jdbcType=INTEGER}, #{picformat,jdbcType=VARCHAR}, ",
            "#{status,jdbcType=INTEGER}, #{size,jdbcType=INTEGER}, #{content,jdbcType=LONGVARBINARY})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "pictureid", before = false, resultType = Long.class)
    int insert(BookPicture record);

    int insertSelective(BookPicture record);

    List<BookPicture> selectByExampleWithBLOBs(BookPictureEx example);

    List<BookPicture> selectByExample(BookPictureEx example);

    @Select({
            "select",
            "PICTUREID, BOOKID, MAINPIC, DISPLAYORDER, PICFORMAT, STATUS, SIZE, CONTENT",
            "from bookpicture",
            "where PICTUREID = #{pictureid,jdbcType=BIGINT}"
    })
    @ResultMap("ResultMapWithBLOBs")
    BookPicture selectByPrimaryKey(Long pictureid);

    int updateByExampleSelective(@Param("record") BookPicture record, @Param("example") BookPictureEx example);

    int updateByExampleWithBLOBs(@Param("record") BookPicture record, @Param("example") BookPictureEx example);

    int updateByExample(@Param("record") BookPicture record, @Param("example") BookPictureEx example);

    int updateByPrimaryKeySelective(BookPicture record);

    @Update({
            "update bookpicture",
            "set BOOKID = #{bookid,jdbcType=BIGINT},",
            "MAINPIC = #{mainpic,jdbcType=BIT},",
            "DISPLAYORDER = #{displayorder,jdbcType=INTEGER},",
            "PICFORMAT = #{picformat,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "SIZE = #{size,jdbcType=INTEGER},",
            "CONTENT = #{content,jdbcType=LONGVARBINARY}",
            "where PICTUREID = #{pictureid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(BookPicture record);

    @Update({
            "update bookpicture",
            "set BOOKID = #{bookid,jdbcType=BIGINT},",
            "MAINPIC = #{mainpic,jdbcType=BIT},",
            "DISPLAYORDER = #{displayorder,jdbcType=INTEGER},",
            "PICFORMAT = #{picformat,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "SIZE = #{size,jdbcType=INTEGER}",
            "where PICTUREID = #{pictureid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BookPicture record);
}
